// pages/rechargecard/collarCard/index.js
var a = getApp(), t = a.requirejs("core"), e = a.requirejs("biz/order"), i = a.requirejs("biz/diypage"), o = (a.requirejs("foxui"),
  a.requirejs("jquery"))
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },
  surecollar(e){
    var that = this;
    
    var mid = e.currentTarget.dataset.mid;
    var rgid = e.currentTarget.dataset.rgid;
    if (that.data.member.error=='10003'){
      a.checkAuth();
    }else{
      t.get('member/usergetrechargecard', { mid: mid, rgid: rgid }, function (e) {
        console.log(e,3454);
        if(e.status=="0")
        {
          wx.showModal({
            title: '友情提示',
            content: '该充值卡已领取。',
            showCancel: false,
            success(res) {
              
            }
          });
        }else{
          console.log(e, 777);
          that.setData({
            user: e.data
          })
          wx.navigateTo({
            url: '/pages/rechargecard/repeatCollar/index',
          })
        }
       
      })
    }

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
   var that=this;
   console.log(options.scene,3333);
    var s = decodeURIComponent(options.scene);
    
    if ( s) {
      var n = t.str2Obj(s);
    console.log(n,66688);
      // var arrPara = s.split("&");
      //  console.log(arrPara,345354345)
      options.id = n.grantid, n.mid && (options.mid = n.mid, a.setCache("usermid", n));  
    }
    console.log(options,77777);
    a.url(options), that.setData({
      cover: !0,
      showvideo: !1
    }), wx.getSystemInfo({
      success: function (t) {
        var a = t.windowWidth / 1.7;
        that.setData({
          swiperheight: a
        });
      }
    });
    t.get('member/getrechargecard', { grantid: options.id },function(e){
         console.log(e,6666);
         that.setData({
           user:e.data
         })
    
    })
  },
    getDiypage: function(t) {
        var e = this;
        o.each(t.diypage.items, function(t, i) {
            if ("topmenu" == i.id) if (e.setData({
                topmenu: i
            }), null == i.data[0]) var s = ""; else {
                s = i.data[0].linkurl;
                a.get("diypage/getInfo", {
                    dataurl: s
                }, function(t) {
                    i.data[0].data = t.goods.list;
                });
            }
            if ("seckillgroup" == i.id) {
                var n = {};
                n.status = i.data.status, n.endtime = i.data.endtime, n.starttime = i.data.starttime, 
                e.initSeckill(n);
            }
        });
    },
  diypageGet: function () {
    var a = this;
    i.get(this, "home", function (e) {
      if (wx.showTabBar({}), a.getDiypage(e), null != a.data.startadv && "" != a.data.startadv) {
        0 != a.data.startadv.status && "" != a.data.startadv || wx.getSetting({
          success: function (t) {
            t.authSetting["scope.userInfo"] && a.get_nopayorder();
          }
        });
        var i = a.data.startadv.params;
        if ("default" == i.style) {
          var s = i.autoclose;
          !function t(e) {
            a.setData({
              clock: s
            }), s <= 0 ? a.setData({
              adveradmin: !1
            }) : setTimeout(function () {
              s -= 1, t(e);
            }, 1e3);
          }(a);
        }
        if (1 == i.showtype) {
          var n = 1e3 * i.showtime * 60, o = t.getCache("startadvtime"), r = +new Date(), d = !0;
          a.setData({
            adveradmin: !0
          }), o && r - o < n && (d = !1), a.setData({
            adveradmin: d
          }), d && t.setCache("startadvtime", r);
        }
        a.data.startadv.status;
      }
    });
  },
  getInfo: function () {
    var that = this;
    t.get("member", {}, function (e) {
      console.log(e, 4444);
      1 == e.isblack && wx.showModal({
        title: "无法访问",
        content: "您在商城的黑名单中，无权访问！",
        success: function (e) {
          e.confirm && t.close(), e.cancel && t.close();
        }
      }), that.setData({
        member: e,
        show: !0,
        customer: e.customer,
        customercolor: e.customercolor || "",
        phone: e.phone,
        phonecolor: e.phonecolor || "",
        phonenumber: e.phonenumber || "",
        iscycelbuy: e.iscycelbuy,
        bargain: e.bargain
        }), e.error;
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getInfo()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})